<?php

/**
 * Application filter form base class.
 *
 * @package    ecollegeplus
 * @subpackage filter
 * @author     Batanayi Matuku
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseApplicationFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'number'             => new sfWidgetFormFilterInput(),
      'first_name'         => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'last_name'          => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'middle_name'        => new sfWidgetFormFilterInput(),
      'email'              => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'program_id'         => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Program'), 'add_empty' => true)),
      'academic_period_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('AcademicPeriod'), 'add_empty' => true)),
      'status'             => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'enquiry_date'       => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'last_activity'      => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'completed'          => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'phone_work'         => new sfWidgetFormFilterInput(),
      'phone_home'         => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'phone_mobile'       => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'gender'             => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'address_line_one'   => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'address_line_two'   => new sfWidgetFormFilterInput(),
      'city'               => new sfWidgetFormFilterInput(),
      'postcode'           => new sfWidgetFormFilterInput(),
      'state_province_id'  => new sfWidgetFormFilterInput(),
      'country_id'         => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Country'), 'add_empty' => true)),
    ));

    $this->setValidators(array(
      'number'             => new sfValidatorPass(array('required' => false)),
      'first_name'         => new sfValidatorPass(array('required' => false)),
      'last_name'          => new sfValidatorPass(array('required' => false)),
      'middle_name'        => new sfValidatorPass(array('required' => false)),
      'email'              => new sfValidatorPass(array('required' => false)),
      'program_id'         => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Program'), 'column' => 'id')),
      'academic_period_id' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('AcademicPeriod'), 'column' => 'id')),
      'status'             => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'enquiry_date'       => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'last_activity'      => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'completed'          => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'phone_work'         => new sfValidatorPass(array('required' => false)),
      'phone_home'         => new sfValidatorPass(array('required' => false)),
      'phone_mobile'       => new sfValidatorPass(array('required' => false)),
      'gender'             => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'address_line_one'   => new sfValidatorPass(array('required' => false)),
      'address_line_two'   => new sfValidatorPass(array('required' => false)),
      'city'               => new sfValidatorPass(array('required' => false)),
      'postcode'           => new sfValidatorPass(array('required' => false)),
      'state_province_id'  => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'country_id'         => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Country'), 'column' => 'id')),
    ));

    $this->widgetSchema->setNameFormat('application_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Application';
  }

  public function getFields()
  {
    return array(
      'id'                 => 'Number',
      'number'             => 'Text',
      'first_name'         => 'Text',
      'last_name'          => 'Text',
      'middle_name'        => 'Text',
      'email'              => 'Text',
      'program_id'         => 'ForeignKey',
      'academic_period_id' => 'ForeignKey',
      'status'             => 'Number',
      'enquiry_date'       => 'Date',
      'last_activity'      => 'Date',
      'completed'          => 'Number',
      'phone_work'         => 'Text',
      'phone_home'         => 'Text',
      'phone_mobile'       => 'Text',
      'gender'             => 'Number',
      'address_line_one'   => 'Text',
      'address_line_two'   => 'Text',
      'city'               => 'Text',
      'postcode'           => 'Text',
      'state_province_id'  => 'Number',
      'country_id'         => 'ForeignKey',
    );
  }
}
